package cn.q3c.stock.commons;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
import org.apache.log4j.Logger;

/**
 * download项目配置信息
 * @author wangxinning
 *
 */
public class Configuration {

	public final static Logger logger = Logger.getLogger(Configuration.class);
	
	private static Configuration instance=new Configuration();
	
	public PropertiesConfiguration getConfig() {
		return config;
	}

	public void setConfig(PropertiesConfiguration config) {
		this.config = config;
	}

	private PropertiesConfiguration config = null;
	
	private Configuration()
	{
		try {
			config = new PropertiesConfiguration("stock.properties");
			
			//此处可以添加监听器，实现动态更新配置文件内容
			config.setReloadingStrategy(new FileChangedReloadingStrategy());
			
		} catch (ConfigurationException e) {
			logger.error("stock.properties文件加载失败", e);
		}
	}
	
	public static Configuration getInstance() {
		return instance;
	}

}